var webpack = require('webpack');
var WebpackDevServer = require('webpack-dev-server');
var config = require('./webpack.config');
var opn = require('opn');
var morgan = require('morgan');

var proxy = [{
  path: '/api/v1/*',
  target: 'http://www.vue-js.com',
  host: 'www.vue-js.com'
}];

var server = new WebpackDevServer(webpack(config), {
  publicPath: config.output.publicPath,
  proxy: proxy
});

server.app.use(morgan());

server.app.get('*', function(req, res) {
  res.sendFile(__dirname + '/index.html')
});

server.listen(5000, function() {
  console.log('server is running at http://localhost:5000/');
  opn('http://localhost:5000/');
});
